package com.onlyphoto.onlymall.mvp.presenter

import android.content.Context
import com.onlyphoto.onlymall.base.BaseEntity
import com.onlyphoto.onlymall.base.BaseNetworkResponse
import com.onlyphoto.onlymall.base.BaseObserver

import com.onlyphoto.onlymall.mvp.contract.CRefund
import com.onlyphoto.onlymall.mvp.model.MRefundImpl
import com.onlyphoto.onlymall.base.BasePresenter
import com.onlyphoto.onlymall.bean.request.RefundBean
import com.onlyphoto.onlymall.bean.response.RefundInfoBean
import com.onlyphoto.onlymall.bean.response.RefundReasonBean


class PRefundImpl(mContext: Context, mView: CRefund.IVRefund) : BasePresenter<CRefund.IVRefund, MRefundImpl>(mContext, mView, MRefundImpl()), CRefund.IPRefund {
    override fun refund(bean: RefundBean) {
        mModel.refund(bean, object :BaseObserver<BaseEntity>(mContext.get()){
            override fun onSuccess(data: BaseEntity?, msg: String?) {
                mView.refundSuccess()
            }

            override fun onCodeError(t: BaseNetworkResponse<BaseEntity>?) {
                mView.showMsg(t?.msg)
            }

            override fun onFailure(e: Throwable?) {
            }

            override fun onRequestStart() {
            }

            override fun onFinally() {
            }

        })
    }

    override fun getRefundReason() {
        mModel.getRefundReason(object :BaseObserver<ArrayList<RefundReasonBean>>(mContext.get()){
            override fun onSuccess(data: ArrayList<RefundReasonBean>?, msg: String?) {
                mView.getRefundReasonSuccess(data!!)
            }

            override fun onCodeError(t: BaseNetworkResponse<ArrayList<RefundReasonBean>>?) {
            }

            override fun onFailure(e: Throwable?) {
            }

            override fun onRequestStart() {
            }

            override fun onFinally() {
            }

        })
    }

    override fun getRefundInfo(getType: Int, orderId: String) {
        mModel.getRefundInfo(getType, orderId, object :BaseObserver<RefundInfoBean>(mContext.get()){
            override fun onSuccess(data: RefundInfoBean?, msg: String?) {
                mView.getRefundInfoSuccess(data!!)
            }

            override fun onCodeError(t: BaseNetworkResponse<RefundInfoBean>?) {
            }

            override fun onFailure(e: Throwable?) {
            }

            override fun onRequestStart() {
            }

            override fun onFinally() {
            }

        })
    }
}
